package autogen;

<%@page import="static hh.EmptyUtil.*" %>
<%
    String doName = toCamelCaseRemovePreAndSuffix(table.tableName, "st", "1");
    String doNameVar = lowerFist(doName);
%>

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import autogen.dao.<%=doName%>Dao;
import autogen.domain.<%=doName%>DO;
import autogen.domain.<%=doName%>PageDTO;
import autogen.service.<%=doName%>Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <%=table.tableName%>表 serviceImpl
 * @author mybatis-orm auto generator
 */
@Service
public class <%=doName%>ServiceImpl implements <%=doName%>Service{

    @Autowired
    <%=doName%>Dao <%=doNameVar%>Dao;
    
    
    @Override
    public boolean create(<%=doName%>DO entity) {
        if (entity == null) return false;
        return <%=doNameVar%>Dao.create(entity);
    }
    
    @Override
    public boolean createBatch(List<<%=doName%>DO> entities) {
        if (entities == null || entities.isEmpty()) return false;
        return <%=doNameVar%>Dao.createBatch(entities);
    }
    
    @Override
    public boolean deleteById(Long id) {
        if (id == null) return false;
        return <%=doNameVar%>Dao.deleteById(id);
    }
    
    @Override
    public boolean deleteBatchByIds(List<Long> ids) {
        if (ids == null || ids.isEmpty()) return false;
        return <%=doNameVar%>Dao.deleteBatchByIds(ids);
    }
    
    @Override
    public boolean delete(<%=doName%>DO entity) {
         if (entity == null) return false;
        return <%=doNameVar%>Dao.delete(new QueryWrapper<>(entity));
    }
    
    @Override
    public <%=doName%>DO findById(Long id) {
        if (id == null) return null;
        return <%=doNameVar%>Dao.findById(id);
    }
    
    @Override
    public List<<%=doName%>DO> listPage(<%=doName%>PageDTO query) {
         if (query == null) return new ArrayList<>(0);
        return <%=doNameVar%>Dao.listPage(query);
    }
   
    @Override
    public List<<%=doName%>DO> list(<%=doName%>DO entity) {
         if (entity == null) return new ArrayList<>(0);
        return <%=doNameVar%>Dao.list(new QueryWrapper<>(entity));
    }
    
    @Override
    public <%=doName%>DO findOne(<%=doName%>DO entity) {
        if (entity == null) return null;
        return <%=doNameVar%>Dao.findOne(new QueryWrapper<>(entity));
    }
    
    @Override
    public boolean updateById(<%=doName%>DO entity) {
        if (entity == null) return false;
        return <%=doNameVar%>Dao.updateById(entity);
    }
    
    @Override
    public boolean updateBatchByIds(List<<%=doName%>DO> entities) {
         if (entities == null || entities.isEmpty()) return false;
        return <%=doNameVar%>Dao.updateBatchByIds(entities);
    }

}
